home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 338_01 / as68.doc < prev    next >
Text File  |  1990-09-23  |  24KB  |  595 lines

  1. as68 - 68000 Assembler, version 1.02
  2.  
  3.  
  4. (c) copyright 1982 Steve Passe  all rights reserved
  5. Modified to support CC68K C Compiler by Brian Brown, Nov 1989
  6.  
  7.  
  8. TABLE OF CONTENTS
  9. Chapter 1 Introduction           1
  10. Chapter 2 Usage                  6
  11. Chapter 3 Pseudo-ops             8
  12. Chapter 4 Mnemonics             11
  13. Chapter 5 Expressions           13
  14. Chapter 6 S File Format         15
  15. Chapter 7 Error Messages        16
  16. Chapter 8 Differences           18
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25. CHAPTER 1
  26. INTRODUCTION
  27. The as68 assembler is a disk to disk assembler for the Motorola 68000
  28. microprocessor chip. Written in the c programming language, it may be used as
  29. a cross assembler on  any machine supporting c, or as a native assembler if
  30. compiled with a c that produces 68000 output. It's directives and mnemonic set
  31. closely follow that of the Motorola Resident Structured Assembler. It has been
  32. altered to accept assembler output from the 68000 C Compiler. This
  33. modification was performed by B Brown at the Central Institute of Technology,
  34. Heretaunga, New Zealand in 1989.
  35.  
  36.  
  37.  
  38. SOURCE PROGRAM
  39. The input to the assembler is an ascii text file, consisting of a series of
  40. statements written in the assembly language. Each statement consists of one or
  41. more fields within a line.
  42.  
  43.  
  44. The assembler is free format within each line, i.e. there is no need to start
  45. a specific field of a statement in a particular column. Fields are separated
  46. from one another with whitespace (tabs or spaces).
  47.  
  48.  
  49.  
  50. STATEMENTS
  51. There are 3 basic statement types. The most common is an assembly language
  52. instruction or mnemonic. It is a command to the assembler to produce a machine
  53. operation code to carry out a specific action.
  54.  
  55.  
  56. The second type of statement is called an assembly directive or pseudo-op.
  57. Pseudo-ops tell the assembler how to assemble the program.
  58.  
  59.  
  60. The third statement type is called a comment. It is ignored by the assembler,
  61. it's purpose being to allow the programmer to insert descriptions of what the
  62. code is doing within the text of the source program. Comments may exist as the
  63. final field of the other two statement types.
  64.  
  65.  
  66. INSTRUCTION STATEMENTS
  67. An instruction statement consists of from one to four fields:
  68.  
  69.   [label] <mnemonic> [operand] [comment]
  70.  
  71.  
  72.  
  73. LABEL FIELD
  74. The first field, the label field, is optional. It is used to create a symbolic
  75. name for the address of the code generated by the following assembler
  76. mnemonic. This label is stored in the symbol table and any references to it
  77. evaluate to the associated address.
  78.  
  79.  
  80. The label field may be the only field of a statement and multiple, label only
  81. fields may follow one another. In all cases the label(s) will evaluate to the
  82. address of the first mnemonic to be assembled after the label(s) is specified.
  83.  
  84.  
  85. Labels are composed of alphanumeric characters and may be up to 30 characters
  86. long. All characters of a label are significant, as is the case of alphabetic
  87. characters (i.e. "Foo" is different than "foo").
  88.  
  89.  
  90. The first character of a label must be either alphabetic or the character '.'
  91. (period). Following characters may also include the underscore (_), dollarsign
  92. ($), and the digits '0' thru '9'.
  93.  
  94.  
  95. Labels starting in any other than the first column must be terminated with a
  96. colon (:). Certain symbols are reserved for the use of the assembler and thus
  97. may not be used as labels. These include "SP", "USP", "SR", "CCR", "A0"
  98. through "A7" and "D0"
  99. through "D7".
  100.  
  101.  
  102. MNEMONIC FIELD
  103. The second field is the mnemonic or assembly instruction field. It will always
  104. be present in a statement except in the case of a label only statement (label
  105. only statements might more properly be described as assembler directives). If
  106. the line is unlabeled the mnemonic field must be preceeded by whitespace.
  107.  
  108.  
  109. A mnemonic will consist of from 3 to 5 ascii characters, the case of which is
  110. not significant. This assembler recognizes the standard Motorola instruction
  111. set. The complete mnemonic instruction set is described in chapter 4,
  112. "Mnemonics". Many 68000 instructions may work on different data sizes.
  113.  
  114.  
  115. The desired data size is specified by appending a length modifier or data size
  116. code to the mnemonic. A '.b' extension specifies a data size of byte (8 bits)
  117. while '.l' will cause the data size to be a long word (32 bits). No extension
  118. will cause the data size to be a word (16 bits).  A '.w' extension may be used
  119. for data sizes of word, although this size is the default and as such the '.w'
  120. modifier is unnecessary.
  121.  
  122.  
  123.  
  124. OPERAND FIELD
  125. The operand field is necessary only for those statements whose mnemonic
  126. requires an operand(s). It will contain one or two operands. When two operands
  127. are present they must be separated with a comma (no whitespace allowed between
  128. operands).
  129.  
  130. The first of two operands is refered to as the source operand while the second
  131. is the destination operand.
  132.  
  133.  
  134.  
  135. COMMENT FIELD
  136. The comment field is optional and consists of all text following the above
  137. fields.
  138.  
  139.  
  140. DIRECTIVES
  141. Label Field - Labels used with directive statements follow the general rules
  142.               of those used in assembly statements with one important
  143.               exception: they may only be used with the following directives:
  144.  
  145.                  1. EQU
  146.                  2. SET
  147.                  3. DC
  148.                  4. DS
  149.  
  150. Directive Field - The directive field contains an instruction to the assembler
  151.               as to how the program should be assembled. This includes such
  152.               things as the base address of the program, setting of symbol
  153.               values, allocation of program memory storage, conditional
  154.               assembly, etc. The complete list of available assembly
  155.               directions is given in chapter 3, "Pseudo-ops".
  156.  
  157. Operand Field - The operand field of a directive statement will consist of
  158.               zero or more operands, as needed by the pseudo-op in question.
  159.               Multiple operands are separated with a comma (,). No whitespace
  160.               may exist between operands.
  161.  
  162. Comment Field - The comment field is identical to that used in instruction
  163.               statements and is optional.
  164.  
  165. Comments - Comments may exist alone as separate statements. In such cases
  166.               an asterisk, (*), must be the first character on the line.
  167.  
  168.  
  169. CHAPTER 2
  170. USAGE
  171.  
  172. Command Line Format - The command line format is:
  173.  
  174.         as68 <sourcefile>[.ext] [option[ option]]
  175.  
  176. where:
  177.  
  178.  sourcefile     is the source file name.
  179.  ext            is an optional file extension identifier. By default the
  180.                 assembler expects source files to have an ext of ".asm".
  181.  option         is one of several possible options in assembly. Whitespace
  182.                 must separate multiple options when they occur. Individual
  183.                 options are described below.
  184.  
  185.  
  186. OPTIONS
  187. The following options are available:
  188.  
  189.  e,       destination of error messages. If absent all error messages will go
  190.           to the console by default. If present, one or more of the following
  191.           destinations may be specified:
  192.                 c       error messages to the console.
  193.                 e       error messages to a file named "sourcefile.err".
  194.                 f       errors reported in listing.
  195.  
  196.  l       destination of assembly listing. If absent no listing is made. One or
  197.          more of the following option extensions are available:
  198.                 c       listing to console.
  199.                 f       listing to a file named "sourcefile.ls"
  200.  
  201.  o       type and destination of object file. If not present the object file
  202.          will be in Motorola 'S' FILE format.
  203.                 s       object to a file named "sourcefile.s19"
  204.                 x       no object file to be made.
  205.  
  206.  s       set the symbol table size. The symbol table requires 8 bytes plus
  207.          the length of the symbol for each entry. The argument should be in
  208.          decimal bytes. The symbol table defaults to 2000 bytes (decimal). To
  209.          reserve 3500 bytes the option would be: 's3500'.
  210.  
  211.  t       truncate source code lines in listing. This